<?php

namespace App\Models\School;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

use App\Models\Subscribe;
use App\Models\Sys;

class Classes extends Model
{

    protected $table = 'jxt_school_classes';

    protected $primaryKey = 'class_id';

    const CREATED_AT = 'create_at';
    const UPDATED_AT = null;

    public function fromDateTime($value){
        return strtotime(parent::fromDateTime($value));
    }

    public function school()
    {
        return $this->belongsTo(Sys\School::class,'school_code','id')
            ->select(['id','school_name','address','province','city','district','status']);
    }

    public function subscribe()
    {
        return $this->hasMany(Subscribe\Info::class, 'class_id');
    }

    public function teacher()
    {
        return $this->hasMany(Teacher::class, 'class_id');
    }

    public function student()
    {
        return $this->hasMany(Student::class, 'class_id');
    }






}
